|
-
Jul 30th, 2007, 08:19 AM
#23
Hyperactive Member
Re: How To Know System Date Format
 Originally Posted by devmaneesh
Sir,
I want to know the code to retrieve the system date format, whether it is dd/MM/yyyy or MM/dd/yyyy or else.
Well, devmaneesh, you have been provided with such code so that if someone has set the system date format to "mmm yy dddd" or even just "d", you can find that out. But you probably don't want that. You just want to know the components of a date.
1) Do this if the date you are interested in is today's date: Use the VB built-in functions MONTH(date), DAY(date), and YEAR(date). These will invariably give you the correct values regardless of the system date format, which you can safely ignore.
2) Do this if the date you are interested in is provided by the user (for example, a birth date): The date so provided should be in a STRING variable. Simply parse that string according to the agreed rule that the user was supposed to follow in providing the date.
3) Do this if the date you are interested in is provided by a database: If the database field format is DATE, use method 1 else use method 2.
If this answers your question, please mark this thread as resolved.
Mac
P.S. If you were happy with one of the solutions that provided the system date format because you actually needed it for some reason, please let us know why that was superior to MONTH(date), etc. Really curious.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|