[英]I have SQL query that cast Date as Binary and then To Hex? How can i write same logic on c#?
怎么寫
SUBSTRING(master.sys.fn_varbintohexstr(CAST(CreatedDate AS BINARY(9))),3,100))
這在C#?
我能找到的最接近的是:
//Get the date
System.DateTime a = System.DateTime.Now;
//Converts it to string
string b = a.ToString("yyyy-MM-dd HH:mm:ss");
System.Console.WriteLine(b);
//Convert to Byte Array
byte[] c = System.Text.Encoding.ASCII.GetBytes(b);
//Convert every byte as hex and join it
string d = "";
foreach (byte e in c)
d += string.Format("{0:x2}", e);
//Show the result
System.Console.WriteLine(d);
但是id的工作方式不同...
我希望這可以幫助您獲得代碼...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.