Avatar billede kgp43 Nybegynder
03. april 2004 - 18:40 Der er 11 kommentarer og
1 løsning

Noget ala timestamp, men med fast tid

hejsa,

Er det muligt at bruge noget andet end timestamp (integreret i mysql/phpadmin), så det kan anvendes som en signup dato? Som det er nu, opdaterer den tiden ved rettelser. Eller skal man til at bruge now() ?
Avatar billede arne_v Ekspert
03. april 2004 - 18:43 #1
Det skal vel være et DATETIME felt ...
Avatar billede arne_v Ekspert
03. april 2004 - 18:44 #2
Hvori du gemmer now() ved oprettelse
Avatar billede kgp43 Nybegynder
03. april 2004 - 19:02 #3
og så kan det anvendes på samme måde som timestamp? (output)
Avatar billede arne_v Ekspert
03. april 2004 - 19:54 #4
Hvad mener præcis med "på samme måde" ?

Det burde være helt uproblematisk at bruge DATETIME
Avatar billede kgp43 Nybegynder
03. april 2004 - 19:59 #5
Okay.

point til dig, hvis du lige laver et svar.
Avatar billede kgp43 Nybegynder
03. april 2004 - 20:01 #6
Hvad er forskellen på TIME og DATETIME?
Avatar billede arne_v Ekspert
03. april 2004 - 20:08 #8
Fra det første link:

DATE
    A date. The supported range is '1000-01-01' to '9999-12-31'. MySQL displays DATE values in 'YYYY-MM-DD' format, but allows you to assign values to DATE columns using either strings or numbers. See section 12.2.1 The DATETIME, DATE, and TIMESTAMP Types.
DATETIME
    A date and time combination. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. MySQL displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format, but allows you to assign values to DATETIME columns using either strings or numbers. See section 12.2.1 The DATETIME, DATE, and TIMESTAMP Types.
TIMESTAMP[(M)]
    A timestamp. The range is '1970-01-01 00:00:00' to sometime in the year 2037. A TIMESTAMP column is useful for recording the date and time of an INSERT or UPDATE operation. The first TIMESTAMP column in a table is automatically set to the date and time of the most recent operation if you don't assign it a value yourself. You can also set any TIMESTAMP column to the current date and time by assigning it a NULL value. See section 12.2 Date and Time Types. From MySQL 4.1 on, TIMESTAMP is returned as a string with the format 'YYYY-MM-DD HH:MM:SS'. If you want to obtain the value as a number, you should add +0 to the timestamp column. Different timestamp display widths are not supported. In MySQL 4.0 and earlier, TIMESTAMP values are displayed in YYYYMMDDHHMMSS, YYMMDDHHMMSS, YYYYMMDD, or YYMMDD format, depending on whether M is 14 (or missing), 12, 8, or 6, but allows you to assign values to TIMESTAMP columns using either strings or numbers. The M argument affects only how a TIMESTAMP column is displayed, not storage. its values always are stored using 4 bytes each. From version 4.0.12, the --new option can be used to make the server behave as in version 4.1. Note that TIMESTAMP(M) columns where M is 8 or 14 are reported to be numbers, whereas other TIMESTAMP(M) columns are reported to be strings. This is just to ensure that you can reliably dump and restore the table with these types! See section 12.2.1 The DATETIME, DATE, and TIMESTAMP Types.
TIME
    A time. The range is '-838:59:59' to '838:59:59'. MySQL displays TIME values in 'HH:MM:SS' format, but allows you to assign values to TIME columns using either strings or numbers. See section 12.2.2 The TIME Type.
Avatar billede arne_v Ekspert
03. april 2004 - 20:08 #9
og et svar
Avatar billede kgp43 Nybegynder
03. april 2004 - 20:56 #10
Ahhh, forstået :)

Kan det ikke lade sig gøre, kun at få dato ud fra et DATETIME så?
Avatar billede arne_v Ekspert
03. april 2004 - 21:09 #11
Jo.

Men hvis du kun vil have datoen så kunne du måske bruge et DATE felt.
Avatar billede kgp43 Nybegynder
03. april 2004 - 21:27 #12
Jeg skal bruge begge ting, så det er fint med DATETIME :)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Computerworld tilbyder specialiserede kurser i database-management

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester