I have a json file. In that file, I have to replace the date and time with today's date and time. How can I do this? This is my file data. In this data i have to replace '2017-01-8--15-59-10' into today's data. again tomorrow I have to replace that data with tomorrow's date.
i tried this but it is not working
var newFName = Regex.Replace(str, DateTime.Today.ToString("yyyy'-'MM'-'dd' 'HH':'mm':'ss"), DateTime.Today("yyyy'-'MM'-'dd' 'HH':'mm':'ss"));
this is my data which i want to edit
string data=@"where POSBill.CreatedOn between 2017-01-8--15-59-10 and @addedtimestamp order by POSBill.CreatedOn limit 2000"
答案 0 :(得分:0)
您可以在工作表开始时保存(或者如果您愿意,可以结束),
在下一个作业运行中,您可以从此表中获取数据。
答案 1 :(得分:0)
由于您的数据字符串似乎表示已使用查询参数(@addedtimestamp
)的数据库查询,因此您只需添加另一个传递所需值的查询参数:
string data = @"where POSBill.CreatedOn between @today and @addedtimestamp order by POSBill.CreatedOn limit 2000"
...使用查询字符串时,只需为现有参数@addedtimestamp
提供此参数的值<{1}}
command.Parameters.AddWithValue("@today", DateTime.Today);
这将提供您想要的动态行为,并为您提供复杂的字符串替换。