GETDATE()

I am trying to use the GETDATE function in Access and keeping getting an operator error.  Below is the code i thought would work to give me the day difference between current date and LastStarted column.  

SELECT dragon.LastLoginName, dragon.LastStarted, GETDATE() CurrentDateTime, DATEDIFF(day,LastStarted,GETDATE()) As Daydiff
FROM dragon INNER JOIN employeeinfo ON dragon.LastLoginName = employeeinfo.LOGNAME;

I also thought i could just input SELECT GETDATE(); in an access query to get the current date/time, but i also get an error when entering that info.
jsawickiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IrogSintaCommented:
To get the current date, use DATE().
To get the current date & time, use NOW()
0
Rey Obrero (Capricorn1)Commented:
<no Points Please.>

GetDate() is an SQL function,
In Access use the functions posted by IrogSinta..  ( kumusta kabayan ?)
0
IrogSintaCommented:
@capricorn1: (Mabuti naman. Ang galing mo pala dito sa EE.)  I'm impressed!
0
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Rey Obrero (Capricorn1)Commented:
<@IrogSinta: email me, see my profile for the addy>
0
jsawickiAuthor Commented:
The change worked, but now everytime i launch the code, it prompts me to enter a date versus performing the calculation automatically.  Why is that and what do i need to do so it just autopopulates.
0
jsawickiAuthor Commented:
Also, when i do enter a date, i get an error in the new column so there is something wrong with my code.
0
IrogSintaCommented:
Could you post your SQL statement so that we could see what's going on?
0
jsawickiAuthor Commented:
SELECT dragon.LastLoginName, dragon.LastStarted, Now() AS Today, DateDiff([day],[LastStarted],Now()) AS LastUsed
FROM dragon INNER JOIN employeeinfo ON dragon.LastLoginName = employeeinfo.LOGNAME;
0
IrogSintaCommented:
Your DateDiff function needs to be DateDiff("d", [LastStarted], Now()) to get the difference in number of days.
0
pteranodon72Commented:
The DATEDIFF function is different in Access as well. The first parameter is a string: "d" for days, "m" for months, "yyyy" for years -- check Access help on DateDiff -- the parameters can be misleading.

SELECT dragon.LastLoginName, dragon.LastStarted, Now() As Today, DATEDIFF("d",LastStarted, Now()) As LastUsed FROM dragon INNER JOIN employeeinfo ON dragon.LastLoginName = employeeinfo.LOGNAME;

HTH,
pT72
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jsawickiAuthor Commented:
Thanks all and the explanation on the difference between Access and SQL.  I am learning from a SQL book, but have an older Access book that didn't discuss this function, but good to know the help shows this info.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.