Re: Insterting date in an MySQL table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/6/04 3:13 AM, "php-db-digest-help@xxxxxxxxxxxxx"
<php-db-digest-help@xxxxxxxxxxxxx> wrote:

Hi Charalambos,

In MSSQL as in most DBMS's the format the date is inserted, the format it is
stored and the format it is retrieved are quite independent.

If inserting the date is working (you are saving the correct date) then all
you need to do is to get the select statement to convert the date to the
format you want and in MSSQL the function to do that is:
   convert(varchar, <your date column>, <the format number>) and the format
number is an integer

I couldn't find the format you were after but try this

  select convert(varchar, getdate(), 102)

Then change the  "." for - and change the getdate() for your date column.

Good Luck,
Frank

> From: "charalambos nicolaou" <npambos@xxxxxxxxxxx>
> Date: Thu, 06 May 2004 13:13:27 +0300
> To: php-db@xxxxxxxxxxxxx
> Subject: Insterting date in an MySQL table
> 
> Hi everyone,
> 
> I want to created a MYSQL table which will get the date in the form
> (YYYY-MM-DD) automatically. I have created the table below but it doesn?t
> get the form of date that I want. It has the form (YYYYMMDDHHMMSS)
> 
> CREATE TABLE questions1 (ID INT NOT NULL AUTO_INCREMENT,name VARCHAR(30),day
> TIMESTAMP,question TEXT,email VARCHAR(30),answer TEXT, PRIMARY KEY(ID));
> 
> Is there any other date field that gets the date form as I want?
> 
> Thanks in advance
> 
> Charalambos Nicolaou


-- 
Frank Flynn
Poet, Artist & Mystic

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux