Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 19th, 2006, 12:38 AM
Authorized User
 
Join Date: Sep 2006
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

 
Old September 19th, 2006, 06:25 AM
Friend of Wrox
 
Join Date: Mar 2004
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
 
Old September 19th, 2006, 06:26 AM
Friend of Wrox
 
Join Date: Mar 2004
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
 
Old September 19th, 2006, 11:37 PM
Authorized User
 
Join Date: Sep 2006
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






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.