Full Version: How to store Current Date/Time
UtterAccess Discussion Forums > Microsoft® Access > Access Date + Time
guyInATL
Hi, What is the proper way to store in a field if I want to store current date AND time as a timestamp. I chose Date/Time as the data type and General Date in the Format. Now I wanted a timestamp whenever a new row is added so I placed =Date() in the default value but it only shows me the date, not the time?

Second question if you know Java: I retrieve this date in a java.sql.date and .toString() shows me the correct result in the default format but when i use the DateFormat.format() method on it, i get a Null Pointer Exception. What could be the problem? Thanks! Mr. R frown.gif
AJS
Welcome to Utter Access!! uarulez2.gif

You use =Now() in the default value instead of =Date()

-AJ
Larry Larsen
Hi
Welcome to Utter Access Forums

Q1) Now()
Q2) Sorry I don't know "Java"..

HTH's
thumbup.gif
Larry Larsen
Hi
Your second question may be "best" placed in the Web Forum / Web Development .
thumbup.gif

Edited by: Larry Larsen on Wed Sep 29 10:43:51 EDT 2004.
arkangel
I am using the Now (function?) but it does not populate in the first record I have created.
Larry Larsen
Hi
Welcome to Utter Access Forums

Another good place to set a record with the current date & time is at table level (Default), so when you create a new record both date & time are stamped against that record.
thumbup.gif
arkangel
Thanks for answering, I think what you are saying, and i am a pretty fresh noob, is if I put the code in the table when the form opens the time and date will be populated in the first record of the form?
Thanks btw for the quick answer.
=0
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.