How to pick the date format as Short Date (dd/mm/yyyy) without the Time in it to be pulled in an Expression?

Issa S.
Issa S. used Ask the Experts™
on
Hi,,,

How to pick the date format as Short Date (dd/mm/yyyy) without the Time in it to be pulled in an Expression?

Although it is formatted on the form as Short Date, I still get the time with it when I build an expression for another Text Box in the same Form.
Also, It is defined in the underlying table as Date/Time formatted as Short Date !

I am interested in dd/mm/yyyy  or  mm/dd/yyyy only for the sake of the table and the Form Expression.

Thanks a lot.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014
Commented:
Format the date in your expression:

Format(YourDateField, "Short Date")

or

Format(YourDateField, "dd/mm/yyyy")
cLng() will throw away the time portion. I would be weary of using format if the code is going to continue working with it. Format will use regional settings, while VBA/SQL always expects US format.
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
Commented:
Another option is the DateValue() function, which strips the decimals (time portion) from a date and returns only the date portion.
Acronis in Gartner 2019 MQ for datacenter backup

It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.

Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
Keep in mind, that the format is only for display.

So if you wish to retain the value and just apply a format, set the Format property to dd/mm/yyyy and the expression to:

    =[YourDateTimeFieldName]

If you wish to strip the time from the value, apply any format you like and use this expression:

    =DateValue([YourDateTimeFieldName])

/gustav
Distinguished Expert 2017
Commented:
If you don't want time to be stored, don't use Now().  Use Date() when populating date fields.  Also, keep in mind that if you use Format(), your date will be converted to a string and henceforth, it will act like a string so NEVER use Format() in a query unless you are expressly formatting a field for export to Excel and you need to control what gets sent.  If you need to format a field on a form or report, use the Format PROPERTY.  That only affects the display.  It does not affect what is stored or how the field is sorted.

Author

Commented:
Thanks to All of you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial