Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Format Datuma u SQL

[es] :: MS SQL :: Format Datuma u SQL

[ Pregleda: 4756 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

CallMeSaMaster

Član broj: 43611
Poruke: 466
*.PPPoE-2860.sa.bih.net.ba.



+1 Profil

icon Format Datuma u SQL08.09.2006. u 13:54 - pre 214 meseci
Ako u bazi imam unesen datum i vrijeme u formatu 08/09/2006 16:15 kako mogu to da convertujem u oblik 09/08/2006 4:15PM(Americki format).
Gdje mogu naci listu mogucih formatiranja datuma u neki od oblika koje mogu izabrati odnosno listu sa svim mogucim converzijama u sql?

 
Odgovor na temu

sivan347
.NET Programer
Beograd

Član broj: 84406
Poruke: 101
*.fiberop.matgnet.com.



Profil

icon Re: Format Datuma u SQL08.09.2006. u 14:02 - pre 214 meseci
U SQL Helpu otkucaj Convert i tu ce ti prikazati kako da konvertujes vremena.
 
Odgovor na temu

goranvuc
Goran Vucicevic
Novi Sad

Član broj: 4934
Poruke: 1846
*.dialup.neobee.net.



+41 Profil

icon Re: Format Datuma u SQL08.09.2006. u 14:07 - pre 214 meseci
Probaj:
Code:

SELECT CONVERT(DATETIME, TvojePolje, 101) AS ToStoTiTreba FROM TvojaTabela


Inace, imas mail od mene.
 
Odgovor na temu

CallMeSaMaster

Član broj: 43611
Poruke: 466
*.PPPoE-1241.sa.bih.net.ba.



+1 Profil

icon Re: Format Datuma u SQL08.09.2006. u 14:31 - pre 214 meseci
Da ovo radi ali ispisuje sve npr

9/8/2006 1:54:24 PM

Kako mogu da kazem da ispise samo

1) Vrijeme bez date
2)Date+Time ali bez sekundi npr 9/8/2006 1:54 PM
 
Odgovor na temu

goranvuc
Goran Vucicevic
Novi Sad

Član broj: 4934
Poruke: 1846
*.dialup.neobee.net.



+41 Profil

icon Re: Format Datuma u SQL08.09.2006. u 14:40 - pre 214 meseci
Da li je polje u koje je upisan podatak o vremenu datetime ili nekog znakovnog tipa?

Kakvog tipa treba da ti bude konvertovana vrednost? Ako moze da bude znakovnog tipa onda treba da iskoristis DATEPART funkciju i da slozis onako kako ti odgovara, naravno - sve to vazi ako ti je polje koje konvertujes datetime tipa (zato sam te pitao ono na pocetku).
 
Odgovor na temu

CallMeSaMaster

Član broj: 43611
Poruke: 466
*.PPPoE-1241.sa.bih.net.ba.



+1 Profil

icon Re: Format Datuma u SQL08.09.2006. u 14:49 - pre 214 meseci
Da polje u koje se upisuje datum je DateTime tipa.

Konvertovana vrednost treba da bude bilo kojeg tipa ali da format bude ispravan.
Kako radi DatePart?

 
Odgovor na temu

goranvuc
Goran Vucicevic
Novi Sad

Član broj: 4934
Poruke: 1846
*.dialup.neobee.net.



+41 Profil

icon Re: Format Datuma u SQL08.09.2006. u 16:35 - pre 214 meseci
DATEPART
Returns an integer representing the specified datepart of the specified date.

Syntax
DATEPART ( datepart , date )

Arguments
datepart

Is the parameter that specifies the part of the date to return. The table lists dateparts and abbreviations recognized by Microsoft® SQL Server™.

Datepart Abbreviations
year yy, yyyy
quarter qq, q
month mm, m
dayofyear dy, y
day dd, d
week wk, ww
weekday dw
hour hh
minute mi, n
second ss, s
millisecond ms


The week (wk, ww) datepart reflects changes made to SET DATEFIRST. January 1 of any year defines the starting number for the week datepart, for example: DATEPART(wk, 'Jan 1, xxxx') = 1, where xxxx is any year.

The weekday (dw) datepart returns a number that corresponds to the day of the week, for example: Sunday = 1, Saturday = 7. The number produced by the weekday datepart depends on the value set by SET DATEFIRST, which sets the first day of the week.

date

Is an expression that returns a datetime or smalldatetime value, or a character string in a date format. Use the datetime data type only for dates after January 1, 1753. Store dates as character data for earlier dates. When entering datetime values, always enclose them in quotation marks. Because smalldatetime is accurate only to the minute, when a smalldatetime value is used, seconds and milliseconds are always 0.

If you specify only the last two digits of the year, values less than or equal to the last two digits of the value of the two digit year cutoff configuration option are in the same century as the cutoff year. Values greater than the last two digits of the value of this option are in the century that precedes the cutoff year. For example, if two digit year cutoff is 2049 (default), 49 is interpreted as 2049 and 2050 is interpreted as 1950. To avoid ambiguity, use four-digit years.

For more information about specifying time values, see Time Formats. For more information about specifying dates, see datetime and smalldatetime.

Return Types
int
 
Odgovor na temu

logic_rabbit
Radenko Zec
banjaluka

Član broj: 74458
Poruke: 271
*.lanaco.com.



+1 Profil

icon Re: Format Datuma u SQL14.09.2006. u 11:39 - pre 214 meseci
SET DATEFORMAT y,m,s prije pocetka upita za americki format.Koliki vi kod pisete momci:-)
Sql server nepodrzava tip podataka TIME samo datetime tako da ce on uvek upisati datum pored vremena ako mu neprosledis datum upisace 1.1.1900.

logic_rabbit (MCAD,MCSD,MCT,MCTS-
Windows development,MCPD)
 
Odgovor na temu

[es] :: MS SQL :: Format Datuma u SQL

[ Pregleda: 4756 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.