#1  
Old 21st February 2004, 05:30 AM
Mark Clark
 
Posts: n/a
Default Date from DateTime field

I want to use sql to get the date from a datetime field. I have written
Select Date(B.EventDate) From HistoricalEvents as B; but it does not
work. What is the correct syntax?

  #2  
Old 21st February 2004, 06:23 AM
Ole Willy Tuv
 
Posts: n/a
Default Re: Date from DateTime field

<< What is the correct syntax? >>

select cast(B.EventDate as date) EventDate
from HistoricalEvents B

Ole Willy Tuv


  #3  
Old 21st February 2004, 06:26 AM
Brian Evans
 
Posts: n/a
Default Re: Date from DateTime field

Mark Clark wrote:
> I want to use sql to get the date from a datetime field. I have written
> Select Date(B.EventDate) From HistoricalEvents as B; but it does not
> work. What is the correct syntax?
>


Hmm round() is supposed to take away the time portion of a datetime
and return just the date but seems to return a numeric value instead.

SELECT ROUND(B.EventDate) from HistoricalEvents B;

Should work to chop off the time portion of a date but currently
doesn't.

Brian Evans
  #4  
Old 21st February 2004, 06:31 AM
Brian Evans
 
Posts: n/a
Default Re: Date from DateTime field

Brian Evans wrote:

> Mark Clark wrote:
>
>> I want to use sql to get the date from a datetime field. I have
>> written Select Date(B.EventDate) From HistoricalEvents as B; but it
>> does not work. What is the correct syntax?
>>

>
> Hmm round() is supposed to take away the time portion of a datetime
> and return just the date but seems to return a numeric value instead.
>
> SELECT ROUND(B.EventDate) from HistoricalEvents B;
>
> Should work to chop off the time portion of a date but currently
> doesn't.
>
> Brian Evans


Opps ROUND is bad to use since it rounds up sometimes.
I usually use TRUNC() in oracle which NexusDB doesn't
have. In Nexus use FLOOR() which in fact does return
a date when the arguement is a date.

SELECT FLOOR(B.EventDate) from HistoricalEvents B;

Brian Evans


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Statement for DateTime Field Carsten Groh nexusdb.public.support.php 2 27th April 2009 11:46 PM
Selecting on Date Field Problem AJ nexusdb.public.support.odbc 2 24th March 2007 09:12 AM
ReportBuilder 7 - doesn't like date/ datetime parameters via RB Explorer William O. nexusdb.public.support.thirdparty 7 13th June 2006 05:11 PM
Selecting the Month of a datetime field Germain Cassiere nexusdb.public.support.sql 1 22nd November 2003 01:05 AM
Assigning NULL to a Prepared SQL DateTime Field M. Said nexusdb.public.support.sql 5 1st October 2003 07:26 AM


All times are GMT +11. The time now is 11:44 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.