billwobo
Posts: 13
|
| Posted: 07/01/2009, 4:26 PM |
|
I'm having trouble with datetime formats. I can't find a way to display any date from my MSSQL connection.
The input textboxes work, they insert a date in the datebase, but no date is ever displayed in the pages. I tried every combination of date format.
I have a MSSQL connection. I use a Date format like this : yyyy-mm-dd HH:nn:ss
But I'm not sure it's the right format for MSSQL. I usely work with MySQL.
I'm using Codecharge 4.2 on XAMPP server using PHP...
Can anybody guide me?
|
 |
 |
damian
Posts: 838
|
| Posted: 07/01/2009, 9:46 PM |
|
im not positive but unless you are using a mssql command to capture the date then the commands and format would be the same as you would use for the mysql database
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
billwobo
Posts: 13
|
| Posted: 07/02/2009, 1:25 PM |
|
So this format would be the right one : yyyy-mm-dd HH:nn:ss?
If it is so, I don't know what to do to display a date. I tried everything. I see a date apear in the Query editor, but no date is displayed in the resulting pages.
|
 |
 |
damian
Posts: 838
|
| Posted: 07/02/2009, 3:53 PM |
|
have you looked in the db itself?
is the date being stored?
check the db settings for date format on that field.
if no date being stored then format is wrong. if date is being stored your display format is incorrect.
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
DonP
|
| Posted: 07/02/2009, 4:05 PM |
|
Perhaps not a real answer, but why not use the Unix timestamp? It
eliminates all such problems while allowing easy date and time displays
and comparisons by using existing PHP functions.
Don (DonP)
billwobo wrote:
> I'm having trouble with datetime formats. I can't find a way to display any
> date from my MSSQL connection.
>
> The input textboxes work, they insert a date in the datebase, but no date is
> ever displayed in the pages. I tried every combination of date format.
>
> I have a MSSQL connection. I use a Date format like this : yyyy-mm-dd
> HH:nn:ss
> But I'm not sure it's the right format for MSSQL. I usely work with MySQL.
>
>
> I'm using Codecharge 4.2 on XAMPP server using PHP...
>
> Can anybody guide me?
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
billwobo
Posts: 13
|
| Posted: 07/05/2009, 10:07 AM |
|
I don't know what a Unix timestamp is.
The date is being stored in the DB. I see it in the Query Editor and if I set my label type to "Text" then I see my date appear as text. But I need a "date" type label to use calendars and order by date.
I tried many combinations of label formats, database format etc... I don't know what I can be doing wrong.
Could it be in the Charset I use?
I also found this thread : http://forums.codecharge.com/posts.php?post_id=106012
I don't know if we have the same problem.
|
 |
 |
billwobo
Posts: 13
|
| Posted: 07/05/2009, 12:07 PM |
|
I looked over the Unix timestamp. It's interesting.
But how do you translate it in the page? Does it work with date SQL queries like Month() or now()?
|
 |
 |
damian
Posts: 838
|
| Posted: 07/05/2009, 3:50 PM |
|
compare the date format data that is actually in your mssql database with what you see in a mysql database that you do know how it works....
i would have thought that it woud be the same
i almost always just use
Format: dd/mm/yyyy
DBFormat: yyyy-mm-dd HH:nn:ss
Another suggestion - try loading up phpinfo() and checking the date on the MSSQL machine.
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
DonP
|
| Posted: 07/05/2009, 11:25 PM |
|
The Unix timestamp is simply an integer so the DB field is set as an
Integer or Large Integer. On your form, just add a hidden form field and
in it put a BeforeShow event (or BeforeInsert event if you want to be
sure to get the date/time of the actual insert) and use the PHP time()
function to fetch the time. See php.net for details on how and what to
present when you want to show it on the screen (if you do show it there
at all). Since it's an integer that is larger for later times and dates,
it's very easy to write programming to compare.
Don (DonP)
billwobo wrote:
> I'm having trouble with datetime formats. I can't find a way to display any
> date from my MSSQL connection.
>
> The input textboxes work, they insert a date in the datebase, but no date is
> ever displayed in the pages. I tried every combination of date format.
>
> I have a MSSQL connection. I use a Date format like this : yyyy-mm-dd
> HH:nn:ss
> But I'm not sure it's the right format for MSSQL. I usely work with MySQL.
>
>
> I'm using Codecharge 4.2 on XAMPP server using PHP...
>
> Can anybody guide me?
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
cb123
|
| Posted: 07/06/2009, 12:47 PM |
|
I used to have the same problem. For what it's worth I solved it by
setting a PHP directive:=
ini_set("mssql.datetimeconvert",0);
By putting this into Common.php, the date always displays correctly.
Hope this helps.
bybillwobo wrote:
> I'm having trouble with datetime formats. I can't find a way to display any
> date from my MSSQL connection.
>
> The input textboxes work, they insert a date in the datebase, but no date is
> ever displayed in the pages. I tried every combination of date format.
>
> I have a MSSQL connection. I use a Date format like this : yyyy-mm-dd
> HH:nn:ss
> But I'm not sure it's the right format for MSSQL. I usely work with MySQL.
>
>
> I'm using Codecharge 4.2 on XAMPP server using PHP...
>
> Can anybody guide me?
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
billwobo
Posts: 13
|
| Posted: 07/06/2009, 4:02 PM |
|
OK but is it only for "Current" timestamps? Can you use a date picker?
I do have date_entered and date_modified fields for which this is very interesting. But what about a field that users need to fill in?
|
 |
 |
damian
Posts: 838
|
| Posted: 07/06/2009, 6:35 PM |
|
did you try cb123's suggestion?
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
billwobo
Posts: 13
|
| Posted: 07/06/2009, 6:41 PM |
|
Wow cb123 you solved this whole issue in one line of code. That was pretty good.
Thank you.
|
 |
 |
billwobo
Posts: 13
|
| Posted: 07/06/2009, 7:32 PM |
|
Yeah damian, I tried cb123's suggestion and it seams to have solved everything.
|
 |
 |
cb123
|
| Posted: 07/06/2009, 11:33 PM |
|
billwobo wrote:
> Wow cb123 you solved this whole issue in one line of code. That was
> pretty good.
>
> Thank you.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
Glad I could help.
Col
|
|
|
 |