[AccessD] Date format problem

Gustav Brock gustav at cactus.dk
Tue Jul 20 09:20:47 CDT 2004


Hi Chester

If the year is saved as 2004 you can retrieve the deca and single
years like this:

  intShortYear = FullYear Mod 100

If FullYear is a String - as in a combobox - you can do this:

  strShortYear = Right(FullYear, 2)

The reason you are confused is that 2004 is a year and not the date
value you expect as you can see from this:

? Format(2004, "mm/dd/yyyy")

If you insist on using Format() you must build a DateTime value from
the year, say 2004-01-01:

  datDate = DateSerial(2004, 1, 1)

Doing so, Format(datDate, "yy") will return "04".

/gustav


> All I want is the last 2 digits of the year. It needs to be that way to
> load into another program.

>> Selected year contains the value 2004. It can contain any year value 
>> from 2001 to 2010 depending on what the user selects from the list 
>> box.
>>
>> The following expression in a query returns 2004    Test:[Forms]![frm
>> Select Date]![selected_year]
>> The following expression returns 05 in a query 
>> Test:Format([Forms]![frm Select Date]![selected_year],"yy")
>> 
>> I an confused as to what is happening here. Help please.




More information about the AccessD mailing list