Hystrix


Il mondo è la totalità dei fatti non delle cose.
Archivio Posts
Anno 2018

Anno 2016

Anno 2015

Anno 2009

Anno 2008

Anno 2007

Anno 2006
Statistiche
  • Views Home Page: 65.119
  • Views Posts: 124.066
  • Views Gallerie: 0
  • n° Posts: 41
  • n° Commenti: 86

Da intervallo di date a uniqueidentifier e viceversa

Ovviamente uno può pure obiettare che questa cosa non serva assolutamente a nulla, ma non bisogna mettere limiti alla provvidenza :-D
Non aggiungo ne commenti ne altro, i tre al mondo a cui potrebbe interessare quello che segue dovrebbero capire. :-D

declare @Dalle datetime, @Alle Datetime,@Id uniqueidentifier
select @Dalle=getdate(),@Alle=Getdate()+1/24.


select @Id=convert(uniqueidentifier,'00000000-' + 
    stuff(left(convert(varchar(36),convert(uniqueidentifier,convert(binary(6),@Dalle))),13),5,0,'-') + '-'+
    stuff(left(convert(varchar(36),convert(uniqueidentifier,convert(binary(6),@Alle))),13),9,1,''))


select @Dalle,@Alle,@Id,
    convert(datetime,convert(binary(6),convert(uniqueidentifier,stuff(substring(convert(varchar(36),@Id),10,14),5,1,'')+'-0000-0000-000000000000'))) da,
    convert(datetime,convert(binary(6),convert(uniqueidentifier,stuff(right(convert(varchar(36),@Id),12),9,0,'-')+'-0000-0000-000000000000'))) a


marc.
Categoria: SQL Server
lunedì, 24 set 2007 Ore. 23.01
Calendario
luglio 2024
lmmgvsd
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234
Ora e Data
Copyright © 2002-2007 - Blogs 2.0
dotNetHell.it | Home Page Blogs
ASP.NET 2.0 Windows 2003