Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 19th, 2006, 12:38 AM
Authorized User
 
Join Date: Sep 2006
Location: , , Australia.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Funny date return

Hey all,

i have a really weird thing happening
The system date is correct
today is 19/09/2006

Dim dateTODAY As Date
Dim strDate As String

dateTODAY = Date
strDate = CDate(dateTODAY)

MsgBox strDate

Returns 15/08/2006

any ideas?

all other computers on the network all say 19/09/2006

any help would be great, cheers

- Max

Reply With Quote
  #2 (permalink)  
Old September 19th, 2006, 06:25 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Why are you doing all those funny things with the date to get a date?

Try this first:
'-----------------------
Dim dtToday As Date

dtToday = Date()

MsgBox dtToday
'------------------------

If you just want a messagebox to show the date, how about:

'-----------------
MsgBox Date()
'-----------------

HTH


mmcdonal
Reply With Quote
  #3 (permalink)  
Old September 19th, 2006, 06:26 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Also, you declare strDate as a String, and then you try to force a date into it using CDate() when you already declared it as a string, not as a date.


mmcdonal
Reply With Quote
  #4 (permalink)  
Old September 19th, 2006, 11:37 PM
Authorized User
 
Join Date: Sep 2006
Location: , , Australia.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The messagebox is irrelovent to my database, just using it to try and get the correct date.

i tried your idea

msgbox date()

an error is thrown saying invalid use of null.
when i hover over date in debug mode, date = null

anyways i did

msgbox DateTime.Date

seems to work fine

thankyou for all your help by the way, still be stuck where i was two weeks ago if it wasn't for you

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return date only...I need your help! billq SQL Server 2000 2 July 1st, 2006 01:56 PM
Almost finished helpful code--funny ambrosia Word VBA 2 March 27th, 2006 09:21 PM
User-Level Security Wizard acting funny Bob Bedell Access 1 January 7th, 2006 02:53 AM
funny results.... richjo100 XSLT 3 September 27th, 2004 05:38 AM
Convert String Date to Date for a SQL Query tdaustin Classic ASP Basics 4 July 7th, 2003 06:01 PM



All times are GMT -4. The time now is 11:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.