Solved

URGENT! MS ACCESS! Querying a Date/Time Field - Need ASAP!

Posted on 2006-07-14
6
154 Views
Last Modified: 2013-12-24
I have a field saved as

7/6/2006 9:00:00 AM

but when I dump the var I get

2006-07-06 09:00:00.0

I need the time as well! Very Critical!

Initial Query
         <cfquery datasource="#Request.App.DS#" name="GetEvent">
         SELECT EventID,
                EventTypeID,
                EventName,
                StartDateTime,
                EndDateTime,
                EventShortDesc,
                EventDescription,
                Location,
                EventURL,
                EventImage,
                ContactName,
                ContactPhone,
                ContactEmail,
                AllDayFlag
           FROM Event
          WHERE EventID = #URL.EventID#
         </cfquery>

I know you can do this via Oracle...I need it for access...
                TO_DATE(TO_CHAR(StartDateTime, 'MM/DD/YYYY HH24:MI'), 'MM/DD/YYYY HH24:MI') AS StartDateTime,
                TO_DATE(TO_CHAR(EndDateTime, 'MM/DD/YYYY HH24:MI'), 'MM/DD/YYYY HH24:MI') AS EndDateTime,






0
Comment
Question by:firstbankak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 15

Expert Comment

by:danrosenthal
ID: 17111125
<CFOUTPUT>
StartDateTime:
#dateformat(GetEvent.StartDateTime,"MM/DD/YYYY")# #timeformat(GetEvent.StartDateTime,"HH:mm")#
<BR>

EndDateTime:
#dateformat(GetEvent.EndDateTime,"MM/DD/YYYY")# #timeformat(GetEvent.EndDateTime,"HH:mm")#
</CFOUTPUT>
0
 
LVL 12

Expert Comment

by:mkishline
ID: 17111162
You should be able to do either:

<cfquery datasource="#Request.App.DS#" name="GetEvent">
         SELECT EventID,
                EventTypeID,
                EventName,
                Format(StartDateTime,"mm/dd/yyyy hh:nn") AS StartDateTime,
                Format(EndDateTime,"mm/dd/yyyy hh:nn") AS EndDateTime,
                EventShortDesc,
                EventDescription,
                Location,
                EventURL,
                EventImage,
                ContactName,
                ContactPhone,
                ContactEmail,
                AllDayFlag
           FROM Event
          WHERE EventID = #URL.EventID#
         </cfquery>

And if that doesn't work, you can always do it when you return the values:
<cfoutput query="GetEvent">
   Start Date: #DateFormat(StartDateTime,"mm/dd/yyyy")# #TimeFormat(StartDateTime,"hh:mm")#
   End Date: #DateFormat(EndDateTime,"mm/dd/yyyy")# #TimeFormat(EndDateTime,"hh:mm")#
</cfoutput>
0
 
LVL 12

Expert Comment

by:mkishline
ID: 17111211
Sorry dan, didn't mean to duplicate your stellar advice ;-)
0
 
LVL 12

Accepted Solution

by:
mkishline earned 500 total points
ID: 17406789
It seems as though both dan and myself offered solutions that would solve firstbankak's problem. Either a point split here (or points to dan if my sql solution wasn't clear enough, since he was faster on the draw) seems most appropriate.

Thanks,
mkishline
0
 

Author Comment

by:firstbankak
ID: 17408001
Please close this question.  The individual who initiated it with me is no longer employed here.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question