469,312 Members | 2,472 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,312 developers. It's quick & easy.

Visual Basic Dates

The date fields being saved by a VB program were being saved
as #2003-11-22#. For reasons unknown to me these dates began
to be saved as "11/22/2003"
All of these dates were made dates with the "DateValue"
instruction and when used as input to Excel both formats
sort as dates but not intermingled. All "11/22/2003"
formated dates sort in date order but before the #2003/11/22#.
What would cause the format of these dates to change and what
can I change to make these date save in the #2003/11/22# format?
I really need help with this problem!
Riley Brice
rb*****@charter.net
Jul 17 '05 #1
8 5155
rb*****@charter.net (Riley) wrote in message news:<92**************************@posting.google. com>...
The date fields being saved by a VB program were being saved
as #2003-11-22#. For reasons unknown to me these dates began
to be saved as "11/22/2003"
All of these dates were made dates with the "DateValue"
instruction and when used as input to Excel both formats
sort as dates but not intermingled. All "11/22/2003"
formated dates sort in date order but before the #2003/11/22#.
What would cause the format of these dates to change and what
can I change to make these date save in the #2003/11/22# format?


Saved where? How are you writing the values out? How are you viewing
these dates?

DateValue returns a VB Date variable which uses an internal format to
hold the information. It can then be displayed any way you want to
and different ways of viewing the information use different defaults.
You need to post sample code showing what you are doing with the
values and provide more context.
Jul 17 '05 #2
Me
Riley wrote:
The date fields being saved by a VB program were being saved
as #2003-11-22#. For reasons unknown to me these dates began
to be saved as "11/22/2003"
All of these dates were made dates with the "DateValue"
instruction and when used as input to Excel both formats
sort as dates but not intermingled. All "11/22/2003"
formated dates sort in date order but before the #2003/11/22#.
What would cause the format of these dates to change and what
can I change to make these date save in the #2003/11/22# format?
I really need help with this problem!
Riley Brice
rb*****@charter.net


No idea why it changed, but using the Format command will force it to
output whatever way you need it.
For example:

<code>

Function find_date() As String

find_date = Format(Now, "ddd, d mmm yyyy hh:mm:ss")

End Function

</code>

Will produce this output:

Sat, 27 Dec 2003 11:27:50
Re

Jul 17 '05 #3
Me
Me wrote:

This does what you need:

<code>

Function find_date() As String

find_date = Format(Now, "yyyy/mm/dd")

End Function

</code>

Output today is:

2003/12/27

Jul 17 '05 #4
Possibly your windows global settings? USA format is mm/dd/yyyy but UK
format for instance is DD/MM/YYYY. Having your global settings wrong
would cause Excel to display standard date format different than you are
used to.

Riley wrote:
The date fields being saved by a VB program were being saved
as #2003-11-22#. For reasons unknown to me these dates began
to be saved as "11/22/2003"
All of these dates were made dates with the "DateValue"
instruction and when used as input to Excel both formats
sort as dates but not intermingled. All "11/22/2003"
formated dates sort in date order but before the #2003/11/22#.
What would cause the format of these dates to change and what
can I change to make these date save in the #2003/11/22# format?
I really need help with this problem!
Riley Brice
rb*****@charter.net


Jul 17 '05 #5

"Riley" <rb*****@charter.net> wrote in message
news:92**************************@posting.google.c om...
The date fields being saved by a VB program were being saved
as #2003-11-22#. For reasons unknown to me these dates began
to be saved as "11/22/2003"
All of these dates were made dates with the "DateValue"
instruction and when used as input to Excel both formats
sort as dates but not intermingled. All "11/22/2003"
formated dates sort in date order but before the #2003/11/22#.
What would cause the format of these dates to change and what
can I change to make these date save in the #2003/11/22# format?
I really need help with this problem!
Riley Brice
rb*****@charter.net


It is possible that a software install may have modified your Regional
Setting (check Control Panel). But as suggested by "Me", you can always use
the format command, e.g. Format(yourdate,"yy/m/d"))
Jul 17 '05 #6
> But as suggested by "Me"...

Is that Me as in **you** or is that Me as in Me (not **me**, but Me)?<g>

Rick
Jul 17 '05 #7
Thanks to all who responded to my problem. You provided the answer that I needed.
Thanks,
Riley
Jul 17 '05 #8

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:ub********************@comcast.com...
But as suggested by "Me"...


Is that Me as in **you** or is that Me as in Me (not **me**, but Me)?<g>

Rick


LOL .. I was confused myself after I posted that message.
Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by pix | last post: by
2 posts views Thread by frossberg | last post: by
21 posts views Thread by Philipp | last post: by
97 posts views Thread by Master Programmer | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.