You are not logged in.

1

Friday, January 11th 2013, 4:04pm

MS SQL database smalldatetime field output

Hey guys I am pulling in some data from MS SQL. One of my field's is a date/time field. When it is displayed in a QTableView it appears in this format "7/25/2012 11:00:00 AM" but I am now using a form and mapping QLineEdit's to the fields but the date/time field is displayed in the QLineEdit in this format "2012-07-25T11:00:00". What I would really like is for me to be able to display the data like this "7/25/2012 11:00 AM" and allow them to enter in data like that and not require the seconds.

And if possible have something like "dd/mm/yyyy hh:mm AM/PM" as the placeholder text when empty so they know the format and then something like
"_ _/_ _/_ _ _ _ _ _:_ _ _ _" when they click in it and the underscores go away as they fill it out..

My main concern is the displaying and entering in a format like this "7/25/2012 11:00 AM" (requiring 0's like 07/25/2012 is fine). The underscores is just something that I think would be a nice thing to add on if possible.

thank you for any help in advance

Junior

Professional

  • "Junior" is male

Posts: 1,623

Location: San Antonio, TX USA

Occupation: Senior Secure Systems Engineer

  • Send private message

2

Friday, January 11th 2013, 4:39pm

Since your mapping - did you try and map QDateTimeEdit so you don't have to change the type?

3

Friday, January 11th 2013, 5:56pm

Since your mapping - did you try and map QDateTimeEdit so you don't have to change the type?
haha nope I feel pretty dumb because of that. I knew there was a QTimeEdit and a QDateEdit but didn't realize there is a QDateTimeEdit. I'm going to try that real quick and hopefully it'll work.