insert datetime based on a date field + fix time (12:00 noon)

insert datetime based on a date field + fix time (12:00 noon)

Post by John David Adams » Thu, 15 May 2003 05:33:18



I not sure how to do this.  I'm creating a table that tells when a
timesheets are due and this is a datetime field (timesheet_due).

The timesheets are due at noon 5 days prior to the check date.  The
check date is from another table that I am using to create the
timesheet table record.

I can't get the syntax right to do this.

insert into ts_table (keyfield, timesheet_due)
  select keyfield, ck_date - 5 units days ???something???
    from pay_table
    where .....

What do I replace ???somthing??? to get 12:00 for the time?

John

 
 
 

insert datetime based on a date field + fix time (12:00 noon)

Post by Jonathan Leffle » Thu, 15 May 2003 14:55:02



> I not sure how to do this.  I'm creating a table that tells when a
> timesheets are due and this is a datetime field (timesheet_due).

> The timesheets are due at noon 5 days prior to the check date.  The
> check date is from another table that I am using to create the
> timesheet table record.

> I can't get the syntax right to do this.

> insert into ts_table (keyfield, timesheet_due)
>   select keyfield, ck_date - 5 units days ???something???
>     from pay_table
>     where .....

> What do I replace ???somthing??? to get 12:00 for the time?

+ 12 UNITS HOUR?

You might want to think in terms of a more accurate statement, but it
is more verbose and what you've got would probably produce the same
answer:

EXTEND(ck_date, YEAR TO MINUTE) - 5 UNITS DAY + 12 UNITS HOUR

--
Jonathan Leffler                   #include <disclaimer.h>

Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/

 
 
 

1. Query datetime-field by date when field contains date + time

I have tablefield (sqlserver2000) which datatype is datetime. I have
inserted value "insert into ... datetimefield = {ts '2001-11-24
08:24:12'}..." in it. How can I find (query) that row by date ?

I have tried :
... where datetimefield like {d '2001-11-24'}...
... where datetimefield = {d '2001-11-24'}...
... where datetimefield like {d '2001-11-24%'}...
... where datetimefield like {d '%2001-11-24%'}...

..but query never returns that row. Whats wrong ?!?!

This works :
... where datetimefield = {ts '2001-11-24 08:24:12'}...
but time is unknown in "real life".

Connectionstring  is like:
"Provider=SQLOLEDB;Data Source=SERVERNAME;Initial
Catalog=tempdbase;User Id=sa;Password="

And same problem in  access database ?
... where datetimefield = #11/24/2001#...
... where datetimefield like #11/24/2001#...

Maybe its better to use string-datatype instead datetime...

Jaska

2. Is RECORDCOUNT supported on Oracle DB?

3. Comparing datetime field (containing date, time values) to a date only string

4. Recordset and return values

5. Concatenating datetime field and int field to make a date time

6. Index Tuning

7. Treating datetime fields as separate date and time fields

8. Wierd beheavior of mouse click and timers.

9. Group by date based on a datetime field

10. Default Date as 12:00 AM

11. insert time into datetime field with SQL?

12. Storing the date and time in a datetime field

13. Current date and time as the Default Value for a DateTime Field