Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create a timestamp 1

Status
Not open for further replies.

jordanking

Programmer
Sep 8, 2005
351
Hello,

This may be a simple one to answer. I am trying to build custom timestamps that are used to query a remote mysql database.

I want to be able to create a time stamp specific to the day, month, year, hour, minute, second.

I have the corresponding php code if the helps:
Code:
if(intval(date('w'))==0){
    $last_cutoff = mktime(13, 0, 0, date('m'), date('d')-2, date('y'));
    $cutoff = mktime(12, 59, 59, date('m'), date('d')+1, date('Y'));
}elseif(intval(date('w'))==1){
    $last_cutoff = mktime(13, 0, 0, date('m'), date('d')-3, date('y'));
    $cutoff = mktime(12, 59, 59, date('m'), date('d'), date('Y'));
}elseif (intval(date('w'))== 2){
    $last_cutoff = mktime(13, 0, 0, date('m'), date('d')-1, date('y'));
    $cutoff = mktime(12, 59, 59, date('m'), date('d'), date('Y'));
}elseif (intval(date('w'))== 3){
    $last_cutoff = mktime(13, 0, 0, date('m'), date('d')-1, date('y'));
    $cutoff = mktime(12, 59, 59, date('m'), date('d'), date('Y'));
}elseif (intval(date('w'))== 4){
    $last_cutoff = mktime(13, 0, 0, date('m'), date('d')-1, date('y'));
    $cutoff = mktime(12, 59, 59, date('m'), date('d'), date('Y'));
}elseif (intval(date('w'))== 5){
    $last_cutoff = mktime(13, 0, 0, date('m'), date('d')-1, date('y'));
    $cutoff = mktime(12, 59, 59, date('m'), date('d'), date('Y'));
}elseif(intval(date('w'))==6){
    $last_cutoff = mktime(13, 0, 0, date('m'), date('d')-1, date('y'));
    $cutoff = mktime(12, 59, 59, date('m'), date('d')+2, date('Y'));
}

So what i am looking for is an equivilant of a "mkTime" function that allows you to specify values for each aspec of the timestamp as this values changes based on which day of the week it is.
 
Have a look at the DateSerial, TimeSerial and Format functions.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
great, thanks PHV

how would i combine these two into one value for a combined timestamp. I tried tot just use the "&" operator but it did not work
 
sorry, did not take long,

here is what i did

dtDate = DateSerial(Year(date), Month(date), Day(date) - 1)
dtTime = TimeSerial(12, 59, 59)
dtCutOff = CDate(dtDate & " " & dtTime)
 
myDateTime = DateSerial(myYear, myMonth, myDay) + TimeSerial(myHour, myMinute, mySecond)
myAnsiTimeStamp = Format(myDateTime, "yyyy-mm-dd hh:nn:ss")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
one quick question

I created this
Code:
        dtCutOff = DateSerial(Year(date), Month(date), Day(date)) + TimeSerial(12, 59, 59)
        dtLastCut = DateSerial(Year(date), Month(date), Day(date) - 1) + TimeSerial(13, 0, 0)
        strSQLCutOff = CStr(Format(dtCutOff, "yyyy-mm-dd hh:nn:ss"))
        strSQLLast = CStr(Format(dtLastCut, "yyyy-mm-dd hh:nn:ss"))
        Debug.Print strSQLCutOff
        Debug.Print strSQLLast

but it outputs this in the immediate window

Code:
20/06/2006 12:59:59 PM 
19/06/2006 1:00:00 PM
is there a reason it replaced the "-" in the format function with "/"

JK
 
How are Dim'ed strSQLCutOff and strSQLLast ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
also, it does not follow the yyyy-mm-dd hh-nn-ss format either
 
sorry,

that was dumb, they were decalred as date but when i changed it to string it works

thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top