English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have 2 textboxes--one to enter date and one to enter time. I want to then concatenate them and store the result in an Access database in general format(YYYYMMDDHHMMSS) Thanks

2006-09-26 03:20:33 · 1 answers · asked by maudelyn g 1 in Computers & Internet Programming & Design

1 answers

what back end language are you using? Also, are you forcing the user to enter data in a specific format?

I assume you are using ASP, which I don't know too much about and that you are doing the second.

ASP should have functions similar to PHP's substring functions.

Using this you should just need to take substrings of the two fields and concatenate them together like this:

//$date is the data from the date entry field $time is from the time field
//$date is assumed to be in the format MM/DD/YYYY
//$time is assumed to be in the format (HH:MM:SS) on a 24 hour clock
$year = substr( $date,6,4 );//substring of date from the 7th position (starting at 0) and going 4 characters
$month = substr( $date,0,2 );//first two characters
$day = substr( $date,3,2 );//4th and 5th character
$hour = substr( $time,0,2 );
$minute = substr( $time,3,2 );
$second = substr($time,6,2);

$accessTimeStamp = $year . $month . $day . $hour . $minute . $second;//concatenates them in the order requested.
?>

2006-09-26 03:58:06 · answer #1 · answered by John J 6 · 0 0

fedest.com, questions and answers