PC Review


Reply
Thread Tools Rate Thread

anther date question

 
 
Southern at Heart
Guest
Posts: n/a
 
      26th Mar 2010
StrDate is assigned todays date with the Now function, the value looks like
this:
3/25/2010 10:36:48 PM

....I need the value to look like this:
2010/03/25
(the month and day have to be 2 digits)

How do I do this?
thanks.
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      26th Mar 2010
"Southern at Heart" <(E-Mail Removed)> wrote in
message news:E67D6548-98E2-4274-B774-(E-Mail Removed)...
> StrDate is assigned todays date with the Now function, the value looks
> like
> this:
> 3/25/2010 10:36:48 PM
>
> ...I need the value to look like this:
> 2010/03/25
> (the month and day have to be 2 digits)
>
> How do I do this?
> thanks.



Is StrDate a variable? if so, what type of variable is it? The prefix
"str" usually denotes a string, but sometimes prefixes can be misleading.

If you just want the date, and not the time, you can assign from the Date()
function, rather than Now() -- look in the online help for a comparison of
Date(), Time(), and Now().

Assuming StrDate is a string variable, then you need to format the date into
the desired string. Try this:

StrDate = Format(Date(), "yyyy/mm/dd")


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
 
Southern at Heart
Guest
Posts: n/a
 
      26th Mar 2010
Assuming StrDate is a string variable, then you need to format the date into
the desired string. Try this:

StrDate = Format(Date(), "yyyy/mm/dd")

....this should do it, as it needs to be a string.
Thanks. I've tried lots of different syntax with that Format function, but
couldn't quite get it.
Cheers.

"Dirk Goldgar" wrote:

> "Southern at Heart" <(E-Mail Removed)> wrote in
> message news:E67D6548-98E2-4274-B774-(E-Mail Removed)...
> > StrDate is assigned todays date with the Now function, the value looks
> > like
> > this:
> > 3/25/2010 10:36:48 PM
> >
> > ...I need the value to look like this:
> > 2010/03/25
> > (the month and day have to be 2 digits)
> >
> > How do I do this?
> > thanks.

>
>
> Is StrDate a variable? if so, what type of variable is it? The prefix
> "str" usually denotes a string, but sometimes prefixes can be misleading.
>
> If you just want the date, and not the time, you can assign from the Date()
> function, rather than Now() -- look in the online help for a comparison of
> Date(), Time(), and Now().
>
> Assuming StrDate is a string variable, then you need to format the date into
> the desired string. Try this:
>
> StrDate = Format(Date(), "yyyy/mm/dd")
>
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
>

 
Reply With Quote
 
Southern at Heart
Guest
Posts: n/a
 
      27th Mar 2010
When I run this code, it changes StartDate to todays date!
StartDate = Format(Date, "yyyy/mm/dd")
....StartDate was something else before it came to this line...
Please help, thanks.
(I'm needing the date to be in that format)
 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      27th Mar 2010
On Fri, 26 Mar 2010 17:35:01 -0700, Southern at Heart
<(E-Mail Removed)> wrote:

>When I run this code, it changes StartDate to todays date!
>StartDate = Format(Date, "yyyy/mm/dd")
>...StartDate was something else before it came to this line...
>Please help, thanks.
>(I'm needing the date to be in that format)


That's precisely what you're telling it to do: call the built in Date()
function, convert it to a yyyy/mm/dd text string using the Format function,
and store that text string in StartDate.

What is the context? Is StartDate a variable, a form control, something else?
Do you have a form control or table field named Date? If so, you're running
into the main reason you should NOT do that - Access getting confused about
whether you mean the field or the builtin function!

--

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically update a cell with a date based on anther cells date GPR GUY Microsoft Excel Misc 2 3rd Nov 2008 03:57 PM
Access a button from anther form Abs Microsoft Access 2 30th Jan 2008 12:50 AM
Go To Definition in anther project =?Utf-8?B?bGpsZXZlbmQy?= Microsoft VB .NET 1 1st Oct 2005 09:18 PM
How to Logon to Anther XP Pro Machine. =?Utf-8?B?TmVpbA==?= Windows XP General 11 21st May 2005 03:04 PM
Anther reort question? David Sherman Spyware Discussion 0 10th Jan 2005 02:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:40 AM.