从字符串中删除朱利安日期 [英] Removing julian dates from strings

查看:80
本文介绍了从字符串中删除朱利安日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,大家有一个问题

我有一列正在查询.

但是该列中包含有和没有朱利安日期的值,我想从这些没有朱利安日期的列中选择不同的值

如果可能的话,有人可以让我资产吗?

值示例:

BTH2010124
BTH2010123
BTH2010135
WCCH2010W

以及我想要的回报
BTH
WCCH2010W

hi guys have a question for you guys

i have a column i am querying.

but the column contains values with and without julian dates in it i want to select the distinct values from these columns without the julian dates

if this is possible can someone please asset me?

Example of values:

BTH2010124
BTH2010123
BTH2010135
WCCH2010W

and the return i want from this
BTH
WCCH2010W

推荐答案

您必须在数据中查找模式.现在,看起来返回的所有带有日期的字符串都以"BTH"开头,并以七个数字结尾.您可以基于此解析它们.

You have to look for patterns in the data. Right now, it looks like all of the strings returned that have the date in them start with "BTH", and end with a string of seven numbers. You could parse them based on that.

string x = "BTH2010124";
string prefix = x.Substring(0,3);
string possibleDate = x.Substring(3, 7);
if (int.TryParse(possibleDate))
{
    // remove the date part from the original string
    x = x.Replace(possibleDate, "");
}

// when you get here, the date will have been removed from x.



如果您无法做出我的假设,那么您将不得不向我们提供有关您的数据的更多信息.



If you can''t make the assumptions I made, then you''re going to have to give us more info about your data.


根据您对我的答复的评论:

如果日期总是在结尾,则可以反转字符串以检索非日期部分,然后将其反转回来:

Based on your comment to my reply:

If the date is always at the end, you could reverse the string retrive the non-date portion, and then reverse it back:

string x = "ABCDEFG2010124";
string prefix = x.Substring(0,x.Length - 7);
string possibleDate = x.Substring(prefix.Length-1, 7);
if (int.TryParse(possibleDate))
{
    // remove the date part from the original string
    x = prefix;

// when you get here, the date will have been removed from x.



这是基本的开发资料.由于只有您才能识别模式,因此只有您才能提出可接受的解析例程.您无法提供要检索的数据的所有变体,因此,除了根据您提供的数据分析我们所知道的信息之外,我们真的无所不能.

现在,该轮到您成为一名程序员并提出您所需的代码了.真的不是那么艰难.



This is basic developemnt stuff. Since only you can identify the patterns, only YOU can come up with an acceptable parsing routine(s). There''s no way you can provide all of the variations of the data you''re retrieving, so there''s really no way we can help beyond analyzing what we know based on what you provide.

Now, it''s YOUR turn to be a programmer and come up with the code you need. It''s really not that frakking hard.


这篇关于从字符串中删除朱利安日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆