Cov txheej txheem:

Cov hnub khaws cia hauv database li cas?
Cov hnub khaws cia hauv database li cas?

Video: Cov hnub khaws cia hauv database li cas?

Video: Cov hnub khaws cia hauv database li cas?
Video: Quas Koj Ntxhais Rau Kuv Tub - Cai Hawj Feat. Maiv Xis Vaj「Official MV」 2024, Kaum ib hlis
Anonim

Lub neej ntawd txoj kev khaws cia a hnub hauv MySQL database yog los ntawm kev siv DATE . Cov qauv tsim nyog ntawm a DATE yog: YYYY-MM-DD. Yog koj sim nkag mus rau a hnub hauv hom ntawv uas tsis yog Xyoo-Hnub-Hnub hom ntawv, nws yuav ua haujlwm tab sis nws yuav tsis yog khaws cia tus hnub tim raws li koj xav.

Ib yam li ntawd, tib neeg nug, hnub khaws cia hauv SQL Server li cas?

Sab hauv hnub tim yog khaws cia ua 2 integer. Thawj tus lej yog tus lej ntawm hnub tim ua ntej lossis tom qab lub hauv paus hnub (1900/01/01). Qhov thib ob tus lej khaws cov lej ntawm moos zuam tom qab ib tag hmo, txhua tus zuam yog 1300 ntawm ib tug thib ob.

Tsis tas li ntawd, dab tsi yog hom ntaub ntawv rau hnub thiab sijhawm hauv MySQL? Cov DATETIME hom yog siv rau qhov tseem ceeb uas muaj ob qho tib si hnub thiab sijhawm ntu. MySQL retrieves thiab tso saib DATETIME tus nqi hauv 'YYYY-MM-DD hh:mm:ss' format. Qhov kev txhawb nqa yog '1000-01-01 00: 00: 00' rau '9999-12-31 23: 59: 59'. Lub TIMESTAMP hom ntaub ntawv yog siv rau qhov tseem ceeb uas muaj ob qho tib si hnub thiab sijhawm ntu.

Tib neeg kuj nug, hnub twg khaws cia hauv Oracle li cas?

Los ntawm lub neej ntawd, Oracle siv CE hnub nkag yog BCE tsis raug siv meej. Oracle Database muaj nws tus kheej propriety hom ntawv rau khaws cia hnub data. Nws siv qhov ntev-ntev ntawm 7 bytes, txhua qhov sib xws rau xyoo pua, xyoo, hli, hnub, teev, feeb, thiab thib ob rau khw hnub data.

Yuav ua li cas hloov hnub tim hom ntawv hauv SQL?

Yuav ua li cas kom tau txais ntau hom SQL Server hnub tim

  1. Siv cov kev xaiv hnub hom nrog rau CONVERT muaj nuj nqi.
  2. Kom tau txais YYYY-MM-DD siv SELECT CONVERT(varchar, getdate(), 23)
  3. Kom tau MM/DD/YYYY siv SELECT CONVERT(varchar, getdate(), 1)
  4. Tshawb xyuas daim ntawv qhia kom tau txais cov npe ntawm txhua hom kev xaiv.

Pom zoo: