如何知道今天是本月的周一,周二,周三等(数量)?(How to know today is which Monday, Tuesday, Wednesday, etc. (in number) of this month?)
我的问题是:
今天的日期和日期是:2016年6月8日星期三。我想知道今天是本月的哪个星期三(如第二个星期三)。 我怎么能用VB .NET做到这一点?
我试过提供的解决方案:
如何获得给定月份的第一周,第二周或上周二(或一周中的任何一天)
此解决方案接受“每日名称”和“每日周数”,并将输出作为日期提供。 我希望结果不同,因为我应该输入日期,结果应该是“当天的日期”和“当前日期名称”,例如“今天是第二个星期三”。
任何帮助将受到高度赞赏。
My question is:
Today's Day and Date are: Wednesday, June 8, 2016. I want to know today is which Wednesday of the current Month (like 2nd Wednesday). How I can do this using VB .NET?
I have tried the solution provided in:
How do I get first, second or last Tuesday (or any day of the week) of a given month
This solution accepts "Name of the Day" and "Week Number of the Day" and provides the output as the Date. I want the results differently as I should input the Date and the result should be the "Day Number of the Day" and "Current Day Name", like "Today is 2nd Wednesday".
Any help will be highly appreciated.
原文:https://stackoverflow.com/questions/37699180
最满意答案
一些提示。
代替
@lawn = Lawn.where("selected = ?", "true")
最好在模型中添加范围。 @lawn是一个对象数组,因此请使用复数。
def display_lawns @lawns = Lawn.all end def display_status @lawns = Lawn.all.where("selected = ?", "true") end
@lawns是一个数组,所以你不能使用
@lawn.description
如果您需要数组的第一项,
@lawn.first.description
可以正常工作<h2><%= @lawns.first.description %></h2> <ul> <% @lawns.each do |lawn| %> <li> <%= lawn.description %> <%= button_to "Select", update_booking_path(booking_id: lawn.booking), remote: true %> </li> <% end %> </ul>
A couple of hints.
Instead of
@lawn = Lawn.where("selected = ?", "true")
Is better to add a scope in your model. @lawn is an array of objects, so use plural.
def display_lawns @lawns = Lawn.all end def display_status @lawns = Lawn.all.where("selected = ?", "true") end
@lawns is an array, so you can't use
@lawn.description
@lawn.first.description
works if you need the first item of the array<h2><%= @lawns.first.description %></h2> <ul> <% @lawns.each do |lawn| %> <li> <%= lawn.description %> <%= button_to "Select", update_booking_path(booking_id: lawn.booking), remote: true %> </li> <% end %> </ul>
相关问答
更多-
这应该工作: def game_params params.require(:game).permit(:player_id, *((0..3).map { |x| "period_#{x}_goals".to_sym })) end This should work: def game_params params.require(:game).permit(:player_id, *((0..3).map { |x| "period_#{x}_goals".to_sym })) end
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
当你说你必须从视图中“调用这个@count变量”时,我不太明白你的意思。 你是不是在你的控制器中设置这个变量? 如果是这样,它应该可以在相关的视图中自动访问。 (你不会“调用”一个变量,你阅读它或设置它。) 其次,你的方法读取每个课程的学生数,然后将其分配给变量@count 。 每次写入该变量时,其先前的值都会被覆盖,因此写入的方法是无用的。 我不确定你要在这里做什么 - 也许是通过预先为每个课程设置这个值来“初始化”控制器? 按照惯例,控制器的show方法显示关联数据库的一行信息。 如果目标是在该视图中显 ...
-
尝试点击lists/tableOrder.json 。 默认格式是.html,这就是它抱怨它无法找到模板的原因。 Attempt to hit lists/tableOrder.json instead. The default format is .html, and that is why it is complaining that it cannot find a template.
-
您还需要创建一个新路线 post 'scrape' => 'posts#scrape', as: :scrape 然后你可以访问scrape_path和scrape_url button_to 'Scrape', scrape_path You need to create a new route as well post 'scrape' => 'posts#scrape', as: :scrape Then you have access to scrape_path and scrape_url ...
-
一些提示。 代替 @lawn = Lawn.where("selected = ?", "true") 最好在模型中添加范围。 @lawn是一个对象数组,因此请使用复数。 def display_lawns @lawns = Lawn.all end def display_status @lawns = Lawn.all.where("selected = ?", "true") end @lawns是一个数组,所以你不能使用@lawn.description 如果您需 ...
-
因此,您需要解析HTML以从中获取信息 例 HTML:如果你想用HTML的片段回应jQuery的GET请求,你可以考虑渲染部分布局 (不包括完整的应用程序布局)。 在您的控制器中,响应可能如下所示: def templates @templates = DocumentTemplate.all if request.xhr? render :partial => 'templates', locals: {:templates => @templates} else # respond with your normal layou ...Action也是一种方法,但是它有一个相应的路径,你可以通过使用它的路径来触发一个动作,但是如果它没有任何与之关联的路径,你就不能调用一个动作。 例如,在rails中,索引,创建,显示,更新,删除和编辑是默认操作,因为所有这些方法都有与之关联的路由。 但是如果你在控制器中定义一个由一个动作调用的方法,但它没有任何与之关联的路由,那么它就是一个方法而不是一个动作。 Action is also a method but it has a corresponding route, you can hit an ...将计算机移动到Taxi模型,如下所示: #model/taxi.rb #please note that this is a class method and not an instance method! def self.compute puts "Address is @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " end 然后你可以打电话给Taxi.compute ,但这可能不是你想要的,因为你可能需要为特定的出租车调用方法,然后你不 ...
相关文章
更多- Java Number类
- Stack Overflow Architecture Update - Now At 95 Million Page Views A Month
- Scaling Pinterest - From 0 To 10s Of Billions Of Page Views A Month In Two Years
- 每日英语:7 Important Questions to Ask Yourself Today
- 使用mybatis执行sql的时候为什么会出现Parameter index out of range (1 > number of parameters, which is 0)?
- E文阅读
- flex 日期转换 灵异事件
- Stocks retreat slightly
- 第30周三
- The Greatest Salesman In the World
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。