none
dat time field default value RRS feed

  • Question

  • i have a time field notation 00:00

    in the table , the default value is 0 everything worked fine.

    now i copied the database to the user , but i get problems with that.

    the field is appearing as 0:00 and i can't input the time, just 1 character.

    i need 00:00 , because by default the time must be midnight

    does this something got to do with the system configuration ?  or what do i wrong ?

    Tuesday, May 24, 2016 12:31 AM

Answers

  • the values you have mentioned above are in " ". this is the reason that it doesn't work.
    I assume that the OP included the quotes characters purely in the context of this thread.  Trying to do so in the properties sheet of a column of date/time data type would result in a type mismatch error, and it would not be possible to save the table definition.  The key point about this thread is that something which works on one machine apparently does not on another.  I have no explanation for this.

    The point about quotes characters does raise an interesting issue which I've found to have confused inexperienced developers on a number of occasions.  This is that the DefaultValue property is always a string expression, and is documented as such, regardless of the data type of the column in question.  A regular request here and elsewhere over the years has been how to carry forward a date from a newly entered record in a form to the next record.  When the following is used in the form's AfterInsert event procedure:

    Me.MyDate.DefaultValue = Me.MyDate

    if the value of MyDate in the current record is (in UK short date format) 04/07/2016, the value appearing as the default in the new record would be 30/12/1899 00:01:15.  This is because 04/07/2016 is being interpreted as an arithmetical expression which evaluates to the number by which 30/12/1899 00:01:15 is represented, date/time values being no more than a 64 bit floating point number under the skin, with zero representing 30/12/1899 00:00:00.  Sometime people will use:

    Me.MyDate.DefaultValue = "#" & Me.MyDate & "#"

    which in my case, with the system short date format set to dd/mm/yyyy, would change 4th July to 7th April.  The correct way is:

    Me.MyDate.DefaultValue = """" & Me.MyDate & """"




    Ken Sheridan, Stafford, England

    Friday, May 27, 2016 10:07 AM

All replies

  • Hi tekoko10,

    if it displays as 0.00 then also you can enter the time.

    you can enter like 12:00

    there is no problem and Access will accept this.

    For default time you need to set the value in design view like below.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, May 25, 2016 3:30 AM
    Moderator
  • My guess is that the column and/or control is formatted as h:nn rather than hh:nn.  The user should still be able to enter any time value, however.

    Ken Sheridan, Stafford, England

    Wednesday, May 25, 2016 10:46 AM
  • That is so strange , it is definitely hh:nn on my computer. And here it appears as 00:00 I copy it to the other computer , and then it changes, i can just enter 1 digit. It is not problem for most of the date time fields, only this particular one. Now i've noticed something else, if i remove the 0 from the default value of that timefield, than i can enter the time ..... I need 00:00 for that field or 0:00 ,so what can i do now ?
    Wednesday, May 25, 2016 7:30 PM
  • Hi tekoko10,

    you have mentioned that you have problem with one date time field and other are working properly.

    you have also mentioned that ,", if i remove the 0 from the default value of that timefield, than i can enter the time"

    which value you have provided as default value in date time field?

    can you remove the default value and try to set it again may solve your issue.

    can you able to change format to hh:nn on another machine on which you have this issue.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 26, 2016 6:12 AM
    Moderator
  • i thought default value 0 for a time field is ok , here on my computer it is , on the other one, it causes problems.

    initially i thought the problem was about the input mask or the format of the time field, now it seems it is the default value

    Thursday, May 26, 2016 12:07 PM
  • can you explain this ? i' ve never seen this ????

    i changed the default value in "#0:00:00#"  , #00:00:00# , "#12:00:00AM#", "0:00"   , "00:00",  ...

    nothing worked,

    then i changed the default value in 23:59 and then i can input the field and everything works fine ...

    i can not understand ...

    Friday, May 27, 2016 4:30 AM
  • >>i can not understand ...<< Nor can I.

    Ken Sheridan, Stafford, England

    Friday, May 27, 2016 5:34 AM
  • Hi tekoko10,

    the values you have mentioned above are in " ". this is the reason that it doesn't work.

    if you remove the  " " form all values then it will automatically converted to #12:00:00AM#.

    23:59 work for you because this time you don't use "".

    Regards

    Deepak 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, May 27, 2016 6:06 AM
    Moderator
  • Ken , If you don't , how can i .. :):):):):)
    Friday, May 27, 2016 8:18 AM
  • the values you have mentioned above are in " ". this is the reason that it doesn't work.
    I assume that the OP included the quotes characters purely in the context of this thread.  Trying to do so in the properties sheet of a column of date/time data type would result in a type mismatch error, and it would not be possible to save the table definition.  The key point about this thread is that something which works on one machine apparently does not on another.  I have no explanation for this.

    The point about quotes characters does raise an interesting issue which I've found to have confused inexperienced developers on a number of occasions.  This is that the DefaultValue property is always a string expression, and is documented as such, regardless of the data type of the column in question.  A regular request here and elsewhere over the years has been how to carry forward a date from a newly entered record in a form to the next record.  When the following is used in the form's AfterInsert event procedure:

    Me.MyDate.DefaultValue = Me.MyDate

    if the value of MyDate in the current record is (in UK short date format) 04/07/2016, the value appearing as the default in the new record would be 30/12/1899 00:01:15.  This is because 04/07/2016 is being interpreted as an arithmetical expression which evaluates to the number by which 30/12/1899 00:01:15 is represented, date/time values being no more than a 64 bit floating point number under the skin, with zero representing 30/12/1899 00:00:00.  Sometime people will use:

    Me.MyDate.DefaultValue = "#" & Me.MyDate & "#"

    which in my case, with the system short date format set to dd/mm/yyyy, would change 4th July to 7th April.  The correct way is:

    Me.MyDate.DefaultValue = """" & Me.MyDate & """"




    Ken Sheridan, Stafford, England

    Friday, May 27, 2016 10:07 AM
  • Ken, Thank you , this is very good explained.

    In my database, i did it the right way, and everything is working as it should be.

    But it does not explain why the problem occurs when i copy it

    I must copy my database to an online server ....... is this one of the worms out of the can , you were talking about in my earlier threads ? i begin to think so....

    Friday, May 27, 2016 12:58 PM
  • Hi tekoko10,

    if the suggestion given by the Ken Sheridan solves your issue then please mark the suggestion given by the Ken Sheridan as an Answer.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 30, 2016 6:30 AM
    Moderator