I'm still having lots of trouble with DateFormat and date arithmetic. The documentation suggests that the DateFormat command should only affect the way a date is displayed, not the way that the system stores it - or have I misunderstood this? I'm storing strings in my database in UK date order, but struggling with date manipulation.
The following code does not work as intended. CDateStr contains the expected value but I thought I would be able to add a week to this (regardless of DateFormat) using DateTime.Add(DateTime.Date(DateTime.Now), 0, 0, 7). However, the value of Main.CExpDate as it appears in my message box is completely garbled. Can anyone see what I'm doing wrong? Both CDateStr and CExpDate are defined as strings.
DateTime.DateFormat = "ddMMyyhhmm"
CDateStr = DateTime.Date(DateTime.Now)
Main.CExpDate = DateTime.Add(DateTime.Date(DateTime.Now), 0, 0, 7)
Msgbox("Date now stored as " & CDateStr & ". Expiry date: " & Main.CExpDate, Main.AppName)
:sign0013: